package com.dong6662.spring.starter;

import com.dong6662.spring.bean.BeanFactory;
import com.dong6662.spring.core.ClassScanner;
import com.dong6662.spring.web.handler.HandlerManager;
import com.dong6662.spring.web.server.TomcatServer;
import java.util.List;

public class MiniSpringApplication {

    public static void run(Class<?> clazz, String[] args) {
        TomcatServer tomcatServer = new TomcatServer(args);
        try{
            //启动服务
            tomcatServer.startServer();
            //clazz.getPackageName();我感觉应该也可以
            List<Class<?>> classes = ClassScanner.scanClasses(clazz.getPackage().getName());
            //初始化bean容器，实现aop
            BeanFactory.initBean(classes);
            //
            HandlerManager.resolveMappingHandler(classes);
        } catch (Exception exception){
            exception.printStackTrace();
        }
    }

}
